<?php

namespace common\helpers;

use Yii;
use yii\helpers\ArrayHelper;

class UiHelper
{
    const STATUS_SUCCESS = "success";
    const STATUS_FAIL = "fail";
    const STATUS_WARNING = "warning";

    const STATUS_NO_STATED = 'muted';
    const STATUS_IN_PROGRESS = 'light-blue';
    const STATUS_FINISH = 'green';

    protected static $SUCCESS_CLASS = "success";
    protected static $FAIL_CLASS = "danger";
    protected static $WARNING_CLASS = "yellow";
    protected static $PRIMARY_CLASS = "primary";
    protected static $INFO_CLASS = "info";
    protected static $MUTED_CLASS = "muted";

    /**
     * 得到一个map中指定key的值，如果没找到，返回 not found
     * @param $mapArr array 查找的数组
     * @param $key string 指定的键
     * @return string 找到的值
     */
    protected static function getValueByKeyInMap($mapArr, $key)
    {
        if (!ArrayHelper::keyExists($key, $mapArr, false)) {
            return Yii::t('app', 'Value Not Found');
        }

        return ArrayHelper::getValue($mapArr, $key);
    }
}
